package net.lab1024.sa.admin.module.business.flow.controller;

import lombok.extern.slf4j.Slf4j;
import net.lab1024.sa.admin.module.business.flow.domain.form.DeployFlowDTO;
import net.lab1024.sa.admin.module.business.flow.domain.form.FlwDeModelAddForm;
import net.lab1024.sa.admin.module.business.flow.domain.form.FlwDeModelQueryForm;
import net.lab1024.sa.admin.module.business.flow.domain.form.FlwDeModelUpdateForm;
import net.lab1024.sa.admin.module.business.flow.domain.vo.FlwDeModelVO;
import net.lab1024.sa.admin.module.business.flow.service.FlwDeModelService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.repository.Deployment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

import java.util.List;

/**
 * 流程设计 Controller
 *
 * @Author ADog
 * @Date 2025-10-06 20:16:41
 * @Copyright 1.0
 */

@Slf4j
@RestController
@Tag(name = "流程设计")
public class FlwDeModelController {

    @Resource
    private FlwDeModelService flwDeModelService;

    @Operation(summary = "分页查询 @author ADog")
    @PostMapping("/flwDeModel/queryPage")
    @SaCheckPermission("flwDeModel:query")
    public ResponseDTO<PageResult<FlwDeModelVO>> queryPage(@RequestBody @Valid FlwDeModelQueryForm queryForm) {
        return ResponseDTO.ok(flwDeModelService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author ADog")
    @PostMapping("/flwDeModel/add")
    @SaCheckPermission("flwDeModel:add")
    public ResponseDTO<String> add(@RequestBody @Valid FlwDeModelAddForm addForm) {
        return flwDeModelService.add(addForm);
    }

    @Operation(summary = "更新 @author ADog")
    @PostMapping("/flwDeModel/update")
    @SaCheckPermission("flwDeModel:update")
    public ResponseDTO<String> update(@RequestBody @Valid FlwDeModelUpdateForm updateForm) {
        return flwDeModelService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author ADog")
    @PostMapping("/flwDeModel/batchDelete")
    @SaCheckPermission("flwDeModel:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return flwDeModelService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author ADog")
    @GetMapping("/flwDeModel/delete/{id}")
    @SaCheckPermission("flwDeModel:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return flwDeModelService.delete(id);
    }
/*
    @Operation(summary = "部署流程 @author ADog")
    @PostMapping("/flwDeModel/deployFlow")
    @SaCheckPermission("flwDeModel:add")
        public void deployFlow(@RequestBody DeployFlowDTO deployFlowDTO) {
        log.info("FlwDeModelController.deployFlow：{}", deployFlowDTO);
        Integer id = deployFlowDTO.getId();
        flwDeModelService.deployFlow(id);
    }
    */
        @Operation(summary = "部署流程 @author ADog")
        @GetMapping("/flwDeModel/deployFlow/{id}")
        @SaCheckPermission("flwDeModel:add")
        public ResponseDTO<String> deployFlow(@PathVariable Integer id ) {
            log.info("FlwDeModelController.id：{}", id);
            return flwDeModelService.deployFlow(id);
        }
}
